import axios from '@/utils/axios';

/* 组织架构树 */
export const getTree = organizationId =>
  axios.get(`/bnd-organization/organizationTree/selectOrganizationTree/${organizationId}`);

/* 组织架构：侧边搜索 */
export const getSearch = ({ organizationId, keyWord }) =>
  axios.get(`/bnd-organization/organizationTree/search/${organizationId}/${keyWord}`);

/* 获取部门下的用户（不包含子部门） */
export const getUsers = data =>
  axios.post('/bnd-organization/organizationDept/selectDeptStaff', data);

/* 根据id获取用户信息 */
export const getUserdetail = ({ organizationId, staffId }) =>
  axios.get(`/bnd-organization/userOrganization/staffDetail/${organizationId}/${staffId}`);

/* 组织架构：添加子部门 */
export const addNode = data =>
  axios.post('/bnd-organization/organizationDept/addOrUpdateDept', data);

/* 组织架构：删除子部门 */
export const deleteNode = id => axios.get(`/bnd-organization/organizationDept/deleteDept/${id}`);

/* 组织架构：重命名 */
export const renameNode = data =>
  axios.post('/bnd-organization/organizationDept/addOrUpdateDept', data);

/* 组织架构：部门迁移 */
export const moveNode = data =>
  axios.post('/bnd-organization/organizationDept/depetMigration', data);

/* 组织架构：置顶 */
export const goTopNode = deptId =>
  axios.get(`/bnd-organization/organizationDept/position/${deptId}/0`);

/* 组织架构：上移 */
export const goUpNode = data => axios.post('/bnd-organization/organizationDept/orderDept', data);

/* 组织架构：下移 */
export const goDownNode = data => axios.post('/bnd-organization/organizationDept/orderDept', data);

/* 组织架构：置底 */
export const goBottomNode = deptId =>
  axios.get(`/bnd-organization/organizationDept/position/${deptId}/1`);

/* 组织架构：企业认证否 */
export const hasAuthOrg = organizationId =>
  axios.get(`/bnd-organization/organization/findCompanyInfoAuthenticationById/${organizationId}`);

/* 组织架构：添加用户 */
export const addUser = data => axios.post('/bnd-organization/userOrganization/addStaff', data);

/* 组织架构：修改用户 */
export const updateUser = data => axios.post('/bnd-organization/userOrganization/editStaff', data);

/* 组织架构：用户部门调整 */
export const moveUser = data =>
  axios.post('/bnd-organization/userOrganization/staffDeptUpdate', data);

/* 组织架构：删除用户 */
export const deleteUser = data => axios.post(`/bnd-organization/userOrganization/delStaff`, data);

/* 组织架构：导出模板 */
export const downloadTemplate = () =>
  axios.get('/bnd-organization/userOrganization/download/template', null, {
    responseType: 'blob',
  });

/* 组织架构：导出人员列表 */
export const exportUsers = data =>
  axios.post('/bnd-organization/userOrganization/exportStaff', data, {
    responseType: 'blob',
  });

/* 组织架构：下载失败记录 */
export const exportError = ({ deptId, organizationId }) =>
  axios.get(
    `/bnd-organization/userOrganization/download/fail?deptId=${deptId}&organizationId=${organizationId}`,
    null,
    {
      responseType: 'blob',
    }
  );

/* 组织架构：导入人员列表 */
export const importUsers = data =>
  axios.upload('/bnd-organization/userOrganization/addEmployeeInfoList', data);

/* 组织架构：获取企业信息 */
export const getOrgInfo = id =>
  axios.get(`/bnd-organization/organization/findCompanyInfoById/${id}`);

/* 组织架构：修改企业信息( 未认证 )*/
export const updateOrgInfo = data =>
  axios.post('/bnd-organization/organization/saveCompanyVerification', data);

/* 组织架构：清除导入记录 */
export const clearRecoad = ({ deptId, organizationId }) =>
  axios.get(
    `/bnd-organization/userOrganization/del/failData?deptId=${deptId}&organizationId=${organizationId}`
  );
